<template>
  <div>
      <el-col :span="24" class="sector">
          <el-col :span="8" :offset="6">
              <el-form :model="sales" status-icon  ref="sales" label-width="100px" class="demo-ruleForm">
                  <el-form-item label="账号" prop="account">
                      <el-input type="text" v-model.lazy="sales.account" autocomplete="off"></el-input>
                  </el-form-item>
                  <el-form-item label="密码" prop="password">
                      <el-input type="password" v-model.lazy="sales.password" autocomplete="off"></el-input>
                  </el-form-item>
                  <el-form-item label="姓名" prop="nickName">
                      <el-input v-model.lazy="sales.nickName"></el-input>
                  </el-form-item>
                  <el-form-item>
                      <el-button type="primary" @click="submitForm('sales')">提交</el-button>
                      <el-button @click="resetForm('sales')">重置</el-button>
                  </el-form-item>
              </el-form>
          </el-col>
      </el-col>
  </div>

</template>

<script>
import api from '../../http/apis/apis';
export default {
  data() {
      return {
        sales: {
          _id:"",
          account: '',
          password: '',
          nickName: ''
        },
      };
    },
    created() {
       this.sales['_id']=sessionStorage.getItem('admin_id'); //销售登录的话从sessionStorage拿到id一遍传给后台
    },
    methods: {
      submitForm(formName) {
        this.$refs[formName].validate(async (valid) => {
          if (valid) {
            const {data} = await api.adminsApi.modOrderStatus(this.sales);
            if(data.status){
                this.$message({
                  message: '修改成功',
                  type: 'success'
                });
                this.sales={}
            }
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
      }
    }
};
</script>

<style lang="scss" scoped>
.sector{
    padding:30px 0;
}
@import '../../assets/scss/public/sector.scss';
</style>